#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll M;
int main() {
    	int a[8]={1,3,5,7,0,2,4,6,};
    	int c[8];
    	int i=0,j=4,k=0;
    	while(k<8){
    		if(a[i]<=a[j]&&j<8&&i<4){
    			c[k++]=a[i++];
			}else if(j<8){
				c[k++]=a[j++];
			}
    		
		}
		cout<<"k="<<k<<endl;
		for(int x=0;x<8;x++){
			cout<<c[x]<<" ";
		}
    return 0;
}

